package ysq.xyg.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ysq.xyg.dao.WithdrawDao;
import ysq.xyg.model.Withdraw;
import ysq.xyg.service.WithdrawService;

import javax.annotation.Resource;
import java.util.List;

/**
 * 提现功能
 *
 * @author congcong tao
 * @date 2018/8/29 17:12
 */
@Service("withdrawService")
public class WithdrawServiceImpl extends BaseServiceImpl<Withdraw> implements WithdrawService {

    @Resource
    private WithdrawDao withdrawDao;
    @Autowired
    public void setWithdrawDao(WithdrawDao withdrawDao) {
        this.baseDao = withdrawDao;
    }

    @Override
    public PageInfo<Withdraw> pageInfo(Withdraw withdraw, int pageSize, int pageNum) {
        PageHelper.startPage(pageNum, pageSize);
        List<Withdraw> list = withdrawDao.selectEntity(withdraw);
        return new PageInfo<Withdraw>(list);
    }

    @Override
    public Withdraw selectEntity(String id) {
        Withdraw record = new Withdraw();
        record.setId(id);
        List<Withdraw> list = withdrawDao.selectEntity(record);
        return list == null || list.size() == 0 ? new Withdraw() : list.get(0);
    }
}
